import React, {Component} from 'react';
import {StyleSheet,View,Text,Button} from 'react-native';
import SplashScreen from 'react-native-splash-screen'

import NavigationUtil from "../navigator/NavigationUtil";

// 广告页
class WelcomePage extends Component {
  componentDidMount() {
    // 渲染完毕，隐藏启动屏
    SplashScreen.hide();

    this.timeId = setTimeout(()=>{
      // 200毫米后跳转到首页homePage
      NavigationUtil.resetToHomePage(this.props)
    },200)
  }

  componentWillUnmount() {
    // 清空定时器
    this.timeId && clearTimeout(this.timeId)
  }

  render() {
    return (
      <View style={styles.container}>
        <Text>WelcomePage</Text>
        <Button onPress={this.goHome} title={'跳转到首页'}/>
      </View>
    );
  }

  goHome = () => {
    NavigationUtil.resetToHomePage(this.props)
  }
}

const styles = StyleSheet.create({
  container:{
    flex:1,
    justifyContent:'space-around',
    alignItems:'center',
  }
});

export default WelcomePage;
